package com.llb666.e.shop.domain.service;

import com.llb666.e.shop.api.dto.CenterUserDto;
import com.llb666.e.shop.domain.entity.Users;
import com.llb666.e.shop.domain.repository.CenterUserRepository;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author 斌~
 * @date 2022/9/12 下午5:36
 */
@Service
@RequiredArgsConstructor(onConstructor_ = {@Autowired})
public class CenterUserService {

    private final CenterUserRepository centerUserRepository;

    /**
     * 根据用户id查询用户信息.
     *
     * @param userId 用户id
     * @return 用户信息
     */
    public Users queryUserInfo(String userId) {
        return centerUserRepository.queryUserInfo(userId);
    }

    /**
     * 用户头像更新.
     *
     * @param userId  用户id
     * @param faceUrl 头像图片地址
     * @return 用户信息
     */
    public Users updateUserFace(String userId, String faceUrl) {
        centerUserRepository.updateUserFace(userId, faceUrl);
        return centerUserRepository.queryUserInfo(userId);
    }

    /**
     * 修改用户信息.
     *
     * @param userId 用户id
     * @param users  入参用户Bo
     * @return 用户信息
     */
    public Users updateUserInfo(String userId, Users users) {
        centerUserRepository.updateUserInfo(userId, users);
        return centerUserRepository.queryUserInfo(userId);
    }
}
